
Cross-validation for the constrained linear least squares for compositional responses and predictors.
cv.olscompcomp(y, x, rs = 5, tol = 1e-4, nfolds = 10,
folds = NULL, seed = NULL)
A matrix with compositional response data. Zero values are allowed.
A matrix with compositional predictors. Zero values are allowed.
The number of times to run the constrained optimisation using different random starting values each time.
The threshold upon which to stop the iterations of the constrained optimisation.
The number of folds to be used. This is taken into consideration only if the folds argument is not supplied.
If you have the list with the folds supply it here. You can also leave it NULL and it will create folds.
You can specify your own seed number here or leave it NULL.
A list including:
The runtime of the cross-validation procedure.
The Kullback-Leibler divergences for all runs.
The Jensen-Shannon divergences for all runs.
The average Kullback-Leibler divergence and average Jensen-Shannon divergence.
The function performs k-fold cross-validation for the least squares regression where the beta coefficients are constained to be positive and sum to 1.
# NOT RUN {
library(MASS)
set.seed(1234)
y <- rdiri(214, runif(3, 1, 3))
x <- as.matrix(fgl[, 2:9])
x <- x / rowSums(x)
mod <- cv.olscompcomp(y, x, rs = 1, tol = 1e-4, nfolds = 5, seed = 12345)
mod
# }
Run the code above in your browser using DataLab